From 39ae3fc6b5ae31036d43c03dad35d6cf81d7a13b Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 8 Mar 2005 10:11:28 +0000 Subject: [PATCH] bitkeeper revision 1.1236.12.4 (422d7a50g-lmMcSI2gKt0v9vRXTjYQ) Clean up timer upcalls to guest kernel. Only send an upcall when timestamp info actually changes. Signed-off-by: Keir Fraser --- xen/arch/ia64/domain.c | 3 --- xen/arch/ia64/patch/linux-2.6.7/time.c | 2 +- xen/arch/x86/domain_build.c | 3 --- xen/arch/x86/time.c | 18 ++++++++++++++---- xen/common/domain.c | 6 ------ xen/common/schedule.c | 18 +++++------------- xen/include/xen/time.h | 2 +- 7 files changed, 21 insertions(+), 31 deletions(-) diff --git a/xen/arch/ia64/domain.c b/xen/arch/ia64/domain.c index 69b0774a80..c5f1533f88 100644 --- a/xen/arch/ia64/domain.c +++ b/xen/arch/ia64/domain.c @@ -555,9 +555,6 @@ int construct_dom0(struct domain *d, #if 0 strcpy(d->name,"Domain0"); #endif - /* Set up shared-info area. */ - update_dom_time(d); - d->shared_info->domain_time = 0; // prepare domain0 pagetable (maps METAphysical to physical) // following is roughly mm_init() in linux/kernel/fork.c diff --git a/xen/arch/ia64/patch/linux-2.6.7/time.c b/xen/arch/ia64/patch/linux-2.6.7/time.c index 5ec93f8bc2..a21c0465c8 100644 --- a/xen/arch/ia64/patch/linux-2.6.7/time.c +++ b/xen/arch/ia64/patch/linux-2.6.7/time.c @@ -71,7 +71,7 @@ + return now; +} + -+void update_dom_time(struct domain *d) ++void update_dom_time(struct exec_domain *ed) +{ +// FIXME: implement this? + printf("update_dom_time: called, not implemented, skipping\n"); diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index c8e378eb00..d2de1138cd 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -406,9 +406,6 @@ int construct_dom0(struct domain *d, #endif /* __x86_64__ */ - /* Set up shared-info area. */ - update_dom_time(d); - d->shared_info->domain_time = 0; /* Mask all upcalls... */ for ( i = 0; i < MAX_VIRT_CPUS; i++ ) d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1; diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index e4d28aa54d..52a086a239 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -13,7 +13,9 @@ * Copyright (C) 1991, 1992, 1995 Linus Torvalds */ +#include #include +#include #include #include #include @@ -273,15 +275,20 @@ s_time_t get_s_time(void) } -void update_dom_time(struct domain *d) +void update_dom_time(struct exec_domain *ed) { + struct domain *d = ed->domain; shared_info_t *si = d->shared_info; unsigned long flags; - read_lock_irqsave(&time_lock, flags); + if ( d->last_propagated_timestamp == full_tsc_irq ) + return; + read_lock_irqsave(&time_lock, flags); spin_lock(&d->time_lock); + d->last_propagated_timestamp = full_tsc_irq; + si->time_version1++; wmb(); @@ -295,8 +302,9 @@ void update_dom_time(struct domain *d) si->time_version2++; spin_unlock(&d->time_lock); - read_unlock_irqrestore(&time_lock, flags); + + send_guest_virq(ed, VIRQ_TIMER); } @@ -322,7 +330,9 @@ void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base) write_unlock_irq(&time_lock); - update_dom_time(current->domain); + /* Others will pick up the change at the next tick. */ + current->domain->last_propagated_timestamp = 0; /* force propagation */ + update_dom_time(current); } diff --git a/xen/common/domain.c b/xen/common/domain.c index c80b9b157f..50e3b85405 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -283,9 +283,6 @@ int final_setup_guest(struct domain *p, dom0_builddomain_t *builddomain) if ( (rc = arch_final_setup_guest(p->exec_domain[0],c)) != 0 ) goto out; - /* Set up the shared info structure. */ - update_dom_time(p); - set_bit(DF_CONSTRUCTED, &p->d_flags); out: @@ -339,9 +336,6 @@ long do_boot_vcpu(unsigned long vcpu, full_execution_context_t *ctxt) goto out; } - /* Set up the shared info structure. */ - update_dom_time(d); - /* domain_unpause_by_systemcontroller */ if ( test_and_clear_bit(EDF_CTRLPAUSE, &ed->ed_flags) ) domain_wake(ed); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index eb2ae6fcac..a0cd4303c2 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -414,10 +414,6 @@ void __enter_scheduler(void) spin_unlock_irq(&schedule_data[cpu].schedule_lock); - /* Ensure that the domain has an up-to-date time base. */ - if ( !is_idle_task(next->domain) ) - update_dom_time(next->domain); - if ( unlikely(prev == next) ) return; @@ -460,10 +456,10 @@ void __enter_scheduler(void) */ clear_bit(EDF_RUNNING, &prev->ed_flags); - /* Mark a timer event for the newly-scheduled domain. */ + /* Ensure that the domain has an up-to-date time base. */ if ( !is_idle_task(next->domain) ) - send_guest_virq(next, VIRQ_TIMER); - + update_dom_time(next); + schedule_tail(next); BUG(); @@ -500,10 +496,7 @@ static void t_timer_fn(unsigned long unused) TRACE_0D(TRC_SCHED_T_TIMER_FN); if ( !is_idle_task(ed->domain) ) - { - update_dom_time(ed->domain); - send_guest_virq(ed, VIRQ_TIMER); - } + update_dom_time(ed); t_timer[ed->processor].expires = NOW() + MILLISECS(10); add_ac_timer(&t_timer[ed->processor]); @@ -515,8 +508,7 @@ static void dom_timer_fn(unsigned long data) struct exec_domain *ed = (struct exec_domain *)data; TRACE_0D(TRC_SCHED_DOM_TIMER_FN); - update_dom_time(ed->domain); - send_guest_virq(ed, VIRQ_TIMER); + update_dom_time(ed); } /* Initialise the data structures. */ diff --git a/xen/include/xen/time.h b/xen/include/xen/time.h index 8bfcaed79e..1e7ba6657e 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -54,7 +54,7 @@ s_time_t get_s_time(void); #define MILLISECS(_ms) (((s_time_t)(_ms)) * 1000000ULL ) #define MICROSECS(_us) (((s_time_t)(_us)) * 1000ULL ) -extern void update_dom_time(struct domain *d); +extern void update_dom_time(struct exec_domain *ed); extern void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base); -- 2.30.2